package com.cxq.finalproject;

import androidx.appcompat.app.AppCompatActivity;
import androidx.navigation.NavController;
import androidx.navigation.Navigation;
import androidx.navigation.ui.AppBarConfiguration;
import androidx.navigation.ui.NavigationUI;

import android.content.Context;
import android.os.Bundle;
import android.util.Log;

import com.google.android.material.bottomnavigation.BottomNavigationView;

import java.lang.reflect.Field;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        BottomNavigationView navView = findViewById(R.id.nav_view);
        //使用自己的图标
        navView.setItemIconTintList(null);
        AppBarConfiguration appBarConfiguration = new AppBarConfiguration.Builder(
                R.id.fragmentHome, R.id.fragmentCategory, R.id.fragmentShoppingCar, R.id.fragmentMe)
                .build();
        //NavController: 在 NavHost 中管理应用导航的对象。当用户在整个应用中移动时，NavController 会安排 NavHost 中目标内容的交换
        NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment);
        NavigationUI.setupActionBarWithNavController(this, navController, appBarConfiguration);
        NavigationUI.setupWithNavController(navView, navController);

        //navHostView:要求其必须包含NavHost的实现类
//        View navHostView = findViewById(R.id.nav_host_fragment);
//        NavController navController = Navigation.findNavController(navHostView);
//        navController.navigate(R.id.to_destination_activity);
        //页面头部标题
//        NavController controller = Navigation.findNavController(this,R.id.nav_host_fragment); //这里的 R.id.fragment 是 activity界面拖进来的 fragment组件（NavHotFragment）
//        NavigationUI.setupActionBarWithNavController(this,controller);
    }
    //设置返回
//    @Override
//    public boolean onSupportNavigateUp() {
//        //return super.onSupportNavigateUp();
//        NavController controller = Navigation.findNavController(this,R.id.nav_host_fragment);
//        return controller.navigateUp();
//    }


}